package com.arrogames.blondbattle.game.graphics 
{
	import com.arrogames.blondbattle.game.combat.Health;
	import starling.display.Image;
	import starling.display.MovieClip;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.textures.Texture;
	import starling.core.Starling;
	import starling.textures.TextureAtlas;
	import com.arrogames.blondbattle.assets.AssetManager;
	
	/**
	 * class that loads the image for the home bases
	 * 
	 * @author A.J. van Steenwijk
	 */
	public class BaseView extends Sprite
	{
		
		private var flagMovie:MovieClip;
		
		public function BaseView(health:Health)
		{
			super();
			var texture:Texture = AssetManager.instance.getTexture("base");
			var baseImage:Image = new Image(texture);
			addChild(baseImage);
			setAnimation();
			var healthBar:HealthBar = new HealthBar(texture.width, 10, health);
			addChild(healthBar);
			healthBar.y = -healthBar.height;
			
			pivotX = texture.width / 2;
			pivotY = texture.height;
		}
		
		private function setAnimation() : void 
		{
			var frames:Vector.<Texture> = AssetManager.instance.getTextures("flag");
			var reversedFrames:Vector.<Texture> = AssetManager.instance.getTextures("flag").reverse();
			var completeFrames:Vector.<Texture> = frames.concat( reversedFrames);
			//add new animation with correct direction
			flagMovie = new MovieClip(completeFrames);
			flagMovie.loop = true;
			
			addChild(flagMovie);
			Starling.juggler.add(flagMovie);
		}
		
	}

}